/**
 *
 */
package com.naiterui.ehp.bp.support.security;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author guoyongxiang
 * @since 1.0.0
 */
public class PatientLoginInterceptor extends AbstractLoginInterceptor {

    private static final Logger LOGGER = LoggerFactory.getLogger(PatientLoginInterceptor.class);

    @Override
    protected void printAccessLog(HttpServletRequest request) {

        String origin = request.getHeader(HeaderConstant.HEADER_ORIGIN);
        String inner = request.getHeader(SettingConfig.HEADER_INNER);
        String platform = request.getHeader(HeaderConstant.HEADER_PLATFORM);
        String version = request.getHeader(HeaderConstant.HEADER_VERSION);
        String h5Version = request.getHeader(HeaderConstant.HEADER_NATIVE_VERSION);
        String url = request.getServletPath();

        String patientId = request.getParameter(SettingConfig.PATIENT_ID);
        String token = request.getParameter(SettingConfig.TOKEN);
        String unionId = request.getParameter(SettingConfig.UNION_ID);

        LOGGER.info("==请求平台来源_p={}, _o={}, 版本号_v={}, _nv={}, inner={}, 请求路径url={}, 请求参数===patientId={},token={}, unionId={}", platform, origin,
                version, h5Version, inner, url, patientId, token, unionId);
    }

    @Override
    protected final void settingNosignUri(List<String> nosignUri) {
        // swagger
        nosignUri.add("/swagger-ui.html");
        nosignUri.add("/webjars/**");
        nosignUri.add("/swagger-resources/**");
        nosignUri.add("/v2/api-docs");

        // 微信联合登录 & 获取验证码 & 升级
        nosignUri.add("/ap/wxLogin/getAppId");
        nosignUri.add("/ap/wxLogin/login");
        // 防刷
        // nosignUri.add("/sms/send");
        nosignUri.add("/ap/checkVersion");
        nosignUri.add("/ap/saveVersion");
        nosignUri.add("/ap/saveH5Version");

        // 登录注册
        nosignUri.add("/ap/patient/login");
        nosignUri.add("/ap/patient/doctor/clinic");
        nosignUri.add("/ap/patient/doctor/clinic/detail");
        nosignUri.add("/ap/patient/regist");
        nosignUri.add("/ap/patient/registAndBind");
        nosignUri.add("/ap/patient/openId");
        nosignUri.add("/ap/patient/dmRegist");

        // 静态基础数据
        nosignUri.add("/ap/initData");
        nosignUri.add("/ap/patient/cacheData");
        nosignUri.add("/ap/patient/params");

        // 视频支付回调
        nosignUri.add("/ap/payDoctor/notifyPayResult");

        // 打赏回调
        nosignUri.add("/ap/pay/sysConfrim");

        // ODC & CRM 相关
        nosignUri.add("/ap/patient/b2c/privateDoctor/my");
        nosignUri.add("/ap/patient/b2c/regPhone");
        nosignUri.add("/ap/patient/b2c/regCallback");
        nosignUri.add("/ap/patient/info");
        nosignUri.add("/ap/patient/crm/patientInfo");

        // 为了IOS审核通过，控制登录框是否展示
        nosignUri.add("/ap/inputBox/displayOrNot");
        nosignUri.add("/ap/inputBox/updateRedisVersion");
        nosignUri.add("/ap/inputBox/getVersionInRedis");

        // 支付相关
        nosignUri.add("/ap/pay/wftCallBack");
        nosignUri.add("/ap/pay/callback");

        // 保险项目短连接处理
        nosignUri.add("/ap/short/**");

        // 金数据量表数据回调
        nosignUri.add("/ap/questionnaire/callback/scale");

        // 肠常美报告回调
        nosignUri.add("/ap/openapi/ccm/report");

        //微信回调
        nosignUri.add("/ap/openapi/wechat");
        //微信jsapi-ticket
        nosignUri.add("/ap/openapi/jsticket");

        //微信患者端
        nosignUri.add("/ap/openapi/patient");
        //微信患者端授权
        nosignUri.add("/ap/openapi/patient/code2token");

        //微信代表端
        nosignUri.add("/ap/openapi/deputy");
        //微信代表端授权
        nosignUri.add("/ap/openapi/deputy/code2token");

        // 协议
        nosignUri.add("/ap/agreement/**");

    }

}
